/**
 * 依赖全局变量 InfoGlobal
 * Created by shopnc on 2015/11/26.
 */
//定义表格
var dtGridColumns = [
    {
        id: 'delFlag',
        type: 'int',
        hideQuery:true,
        'export':false,
        hideQueryType:'eq',
        hideQueryValue:1,
        hide:true
    },
    {
        id: 'id',
        title: '编号',
        type: 'number',
        columnClass: 'text-center width-100',
        fastSort: true,
        fastQuery: false
    },
    {
        id: 'agent.name',
        type: 'string',
        title: '代理商',
        headerClass: 'text-left width-100',
        columnClass: 'text-left width-100',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'eq'
    },
    {
        id: 'direction',
        title: '资金方向',
        type: 'number',
        headerClass: 'text-center',
        columnClass: 'text-center',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'eq',
        codeTable: {
            1: $lang.agentDirection.payment,
            2: $lang.agentDirection.receive,
            3: $lang.agentDirection.freeze,
        }
    },
    {
        id: 'type',
        title: '类型',
        type: 'int',
        headerClass:'text-center',
        columnClass:'text-center',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'eq',
        codeTable: {
            1: $lang.agentCapitalLog.recharge,
            2: $lang.agentCapitalLog.cash,
            3: $lang.agentCapitalLog.pay,
            4: $lang.agentCapitalLog.overfee,
            5: $lang.agentCapitalLog.fee,
            6: $lang.agentCapitalLog.cc
        }
    },
    {
        id: 'amount',
        title: '操作金额',
        type: 'number',
        headerClass: 'text-center',
        columnClass: 'text-center',
        fastSort: false,
        fastQuery: false
    },
    {
        id: 'total',
        title: '总额',
        type: 'number',
        headerClass: 'text-center',
        columnClass: 'text-center',
        fastSort: false,
        fastQuery: false
    },
    {
        id: 'createTime',
        title: '创建时间',
        type: 'date',
        format:'yyyy-MM-dd hh:mm:ss',
        headerClass: 'text-center width-300',
        columnClass: 'text-center width-300',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'range'
    },
];

var dtGridOption = {
    lang: 'zh-cn',
    ajaxLoad: true,
    loadURL: ncGlobal.adminRoot + 'capital/json/list',
    exportURL: ncGlobal.adminRoot + 'capital/json/export',
    exportFileName: '代理商资金列表',
    columns: dtGridColumns,
    gridContainer: 'dtGridContainer',
    toolbarContainer: 'dtGridToolBarContainer',
    tools: 'refresh|faseQuery|export[excel]',
    pageSize: 10,
    pageSizeLimit: [10, 20, 50],
    ncColumnsType: {int:["id","direction","status"],Timestamp: ["createTime"]}
};



var grid = $.fn.DtGrid.init(dtGridOption);
//排序
grid.sortParameter.columnId = ['desc_id'];
//默认查询条件
grid.fastQueryParameters = new Object();
grid.fastQueryParameters['eq_delFlag'] = 1;


/**
 * 资金记录列表所使用的js
 */
var information = function () {

    /**
     * 模糊查询
     * @private
     */
    function _bindEvent() {
        //模糊搜索
        $('#customSearch').click(function () {
            grid.fastQueryParameters = new Object();
            grid.fastQueryParameters['eq_delFlag'] = 1;
            grid.fastQueryParameters['lk_agent.name'] = $('#keyword').val();
            grid.pager.startRecord = 0;
            grid.pager.nowPage = 1;
            grid.pager.recordCount = -1;
            grid.pager.pageCount = -1;
            grid.refresh(true);
        });

        //去除输入框回车键提交
        $("input").on("keydown", function (e) {
            if (e.keyCode == 13) {
                e.preventDefault();
                var a = $("#releasePrice");
                a.length && a.trigger("click");
            }
        });

    }

    //外部可调用
    return {
        init: function () {
            _bindEvent();
        }
    }
}();

$(function () {
    grid.load();
    information.init();
})





